Introducción a R

Crear código en R, uso colaborativo y reproducible

  • Introducción
  • Escribir en R
  • Buenas prácticas
  • Uso colaborativo

Datos georeferenciados

library(rgbif)
library(ggplot2)
library(rnaturalearth)
library(sf)

datos <- occ_search(scientificName = "Lynx pardinus", limit = 100)
#head(datos$data[, c("species", "decimalLatitude", "decimalLongitude")])
df <- datos$data

# Basic map
world <- ne_countries(scale = "medium", returnclass = "sf")

# Plot
ggplot() +
  geom_sf(data = world, fill = "black", color = "grey30") +
  geom_point(data = df, aes(x = decimalLongitude, y = decimalLatitude),
             color = "darkred", size = 2, alpha = 0.7) +
  coord_sf() +
  theme_minimal()
# Basic map
spain <- ne_countries(country=c("spain", "portugal"))
plot(spain)

# Plot

ggplot() +
  geom_sf(data = spain, fill = "grey99", color = "grey30") +
  geom_point(data = df, aes(x = decimalLongitude, y = decimalLatitude),
             color = "darkgreen", size = 2, alpha = 0.7) +
  coord_sf() +
  theme_minimal()

Mapa plantas

library(FloraIberica)
map_distribution(genus = "Lavandula", species = "stoechas", size = 0.9)